package com.quzi.kettle.utils;



import com.quzi.kettle.GlobalConfig;

import android.content.Context;
import android.content.SharedPreferences;

public class MSharePerference {

	private static final String Midea_PREFERENCSE = "Kettle";
	private Context context;
	private static MSharePerference instance = null;
	private SharedPreferences sharedPreferences;

	private MSharePerference(Context context) {
		this.context = context;
		sharedPreferences = context.getSharedPreferences(Midea_PREFERENCSE, Context.MODE_PRIVATE);
	}

	public static MSharePerference getInstance(Context context) {
		if (instance == null) {
			instance = new MSharePerference(context);
		}
		return instance;
	}

	/**
	 * -2为没有保存过这个值
	 * 
	 * @param key
	 * @return
	 */
	public int getInt(String key) {
		return sharedPreferences.getInt(key, -2);

	}

	public void updateInt(String key, int value) {
		sharedPreferences.edit().putInt(key, value).commit();
	}

	public String get(String key) {
		return sharedPreferences.getString(key, "");
	}

	public void update(String key, String value) {
		sharedPreferences.edit().putString(key, value).commit();
	}

	public void delete(String key) {
		sharedPreferences.edit().remove(key).commit();
	}

	public void updateBoolean(String key, boolean isCheck) {
		sharedPreferences.edit().putBoolean(key, isCheck).commit();
	}

	public boolean getBoolean(String key) {
		return sharedPreferences.getBoolean(key, false);
	}

}
